<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:c="livcos.org/ns/cosmos"
  xmlns:doc="livcos.org/ns/doc"
  xmlns:ddl="livcos.org/ns/db/ddl"
  xmlns:pm="livcos.org/ns/pm"
  xmlns:sd="livcos.org/ns/design/system"
  xmlns:f="livcos.org/ns/xslt/function"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:v="livcos.org/ns/view"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  exclude-result-prefixes="c doc ddl pm sd f v xs">
  
	<xsl:import href="table.xsl"/>
	<xsl:import href="view_db.xsl"/>
	<xsl:import href="procedure.xsl"/>
	<xsl:import href="function.xsl"/>
	
	<xsl:template match="/ddl:table | /ddl:view | /ddl:procedure | /ddl:function" priority="2">
		<html id="{$callerObjId}">
			<v:head>
				<v:title>
					<xsl:call-template name="ddl-search">
						<xsl:with-param name="label">
							<xsl:apply-templates select="." mode="ddl_title"/>
						</xsl:with-param>
						<xsl:with-param name="query" select="@name"/>
					</xsl:call-template>
				</v:title>
				<v:context>
					<xsl:if test="@catalog"><xsl:value-of select="@catalog"/>.</xsl:if>
					<xsl:value-of select="@schema"/>
				</v:context>
			</v:head>
			<body>
				<v:chapter id="{f:object-id(.)}">
					<v:style ref="{resolve-uri('styles.css')}"/>
					<v:title path="title">Übersicht</v:title>
					<xsl:apply-templates select="." mode="ddl_content"/>
				</v:chapter>
			</body>
		</html>
	</xsl:template>
	
	<xsl:template match="ddl:table" mode="ddl_title">Table <xsl:value-of select="@name"/></xsl:template>
	<xsl:template match="ddl:view" mode="ddl_title">View <xsl:value-of select="@name"/></xsl:template>
	<xsl:template match="ddl:procedure" mode="ddl_title">Stored Procedure <xsl:value-of select="@name"/></xsl:template>
	<xsl:template match="ddl:function" mode="ddl_title">Function <xsl:value-of select="@name"/></xsl:template>
	
	<xsl:template match="ddl:table | ddl:view | ddl:procedure | ddl:function">
		<v:chapter id="{f:object-id(.)}">
			<v:style ref="{resolve-uri('styles.css')}"/>
			<v:title path="title"><xsl:apply-templates select="." mode="ddl_title"/></v:title>
			<xsl:apply-templates select="." mode="ddl_content"/>
		</v:chapter>
	</xsl:template>
		
</xsl:stylesheet>
